#!/usr/bin/env python
"""
# -*- coding: utf-8 -*-
# @Time    : 2020/9/24 11:27
# @Author  : AshJo
# @Desc    : 用户登录注册
# @Filename: user_login.py
# @Version : v1.0
"""


class User:
    def __init__(self, name, pwd):
        self.name = name
        self.pwd = pwd


class Account:
    def __init__(self):
        self.user_list = []

    def login(self):
        username = input('输入登录的用户名：')
        password = input(f'输入用户{username}的密码：')
        for user in self.user_list:
            if username == user.name and password == user.pwd:
                print('登录成功！')
            else:
                print('登录失败！')

    def register(self):
        username = input('输入新注册的用户名：')
        password = input(f'输入用户{username}的密码：')
        password2 = input(f'再次输入用户{username}的密码：')
        if password == password2:
            user = User(username, password)
            self.user_list.append(user)
            print('注册用户成功！')
        else:
            print('两次输入密码不一致')

    def run(self):
        opt_lst = ['注册', '登录']
        while True:
            for index, item in enumerate(opt_lst, 1):
                print(index, item)
            choose = input('请输入操作的序号：').strip()
            if choose == '1':
                self.register()
            elif choose == '2':
                self.login()
            elif choose.upper() == 'Q':
                break


if __name__ == '__main__':
    obj = Account()
    obj.run()
